<?php
namespace api\controllers;

use Yii;
use yii\rest\ActiveController;
use yii\data\ActiveDataProvider;
use api\models\Ret;
use api\models\ApiLoginForm;
use common\models\Account;


class AccountController extends ActiveController
{
    public $modelClass = 'common\models\Account';
    
    public function actionLogin()
    {
        $model = new ApiLoginForm();
        $model->username = Yii::$app->request->post("username");
        $model->password = Yii::$app->request->post("password");

        if($model->login()){
            $token = $model->login();
            $account = new Account();
            $data = $account->getAccountByToken($model->login());
            $data['token'] = $model->login();
            return  new Ret(1,'登陆成功', $data);
        }else{
            return  new Ret(-1,'登陆失败', []);
        }
    }
}
